

#include <math/sphere.h>


ceSphere::ceSphere ()
	: _center (0, 0, 0)
	, _radius (1.0)
{
}

ceSphere::ceSphere (float radius)
	: _center (0, 0, 0)
	, _radius (radius)
{
}

ceSphere::ceSphere (const ceVector3f& center, float radius)
	: _center (center)
	, _radius (radius)
{
}

void ceSphere::SetCenter (const ceVector3f& center)
{
	_center = center;
}

const ceVector3f& ceSphere::GetCenter () const
{
	return _center;
}

ceVector3f& ceSphere::GetCenter () 
{
	return _center;
}


void ceSphere::SetRadius (float radius)
{
	_radius = radius;
}

float ceSphere::GetRadius () const
{
	return _radius;
}

float ceSphere::GetMinDistance (const ceVector3f& pos) const
{
	float d = (_center - pos).Length () - _radius;
	if (d < 0.0f)
		{
			d = 0.0f;
		}
	return d;
}


float ceSphere::GetMaxDistance (const ceVector3f& pos) const
{
	return (_center - pos).Length () + _radius;
}

